import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [

  {
    path: '/',
    redirect: '/weblogin',
  },

  {
    path: '/weblogin',
    name: 'login',
    component: () => import( '../views/login')
  },
  {
    name: 'index',
    path: '/index',
    // 异步引入组件
    component: () => import('@/views/index.vue'),
    children: [
      {
        name: 'fault',
        path: '/fault',
        // 异步引入组件
        component: () => import('@/views/guzhang/Fault'),
      },
      {
        name: 'achievements',
        path: '/achievements',
        // 异步引入组件
        component: () => import('@/views/jixiao/Achievements'),
      },
      {
        name: 'personal',
        path: '/personal',
        // 异步引入组件
        component: () => import('@/views/renyuan/Personal'),
      },
      {
        name: 'jurisdiction',
        path: '/jurisdiction',
        // 异步引入组件
        component: () => import('@/views/renyuan/Jurisdiction'),
      },
      {
        name: 'admin',
        path: '/admin',
        // 异步引入组件
        component: () => import('@/views/renyuan/Admin'),
      },
      {
        name: 'log',
        path: '/log',
        // 异步引入组件
        component: () => import('@/views/rizhi/Log'),
      },
      {
        name: 'clue',
        path: '/clue',
        // 异步引入组件
        component: () => import('@/views/xiansuo/Clue'),
      },
      {
        name: 'examination',
        path: '/examination',
        // 异步引入组件
        component: () => import('@/views/xiansuo/Examination'),
      },
      {
        name: 'image',
        path: '/image',
        // 异步引入组件
        component: () => import('@/views/xuancuan/Image'),
      },
    ]
  },


];
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
  mode: 'history',
  routes
})

export default router
